package com.stylefeng.guns.core.base.tips;

import com.stylefeng.guns.core.exception.GunsExceptionEnum;

import java.io.Serializable;

/**
 * 返回给前台的提示（最终转化为json形式）
 *
 * @author fengshuonan
 * @Date 2017年1月11日 下午11:58:00
 */
public abstract class Tip<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    protected int code;
    protected String message;
    protected T data;
    protected long time;

    public Tip() {

    }

    public Tip(GunsExceptionEnum e) {
        this(e.getCode(), e.getMessage(), null);
    }

    public Tip(GunsExceptionEnum e, T data) {
        this(e.getCode(), e.getMessage(), data);
    }

    public Tip(int code, String message, T data) {
        this.time = System.currentTimeMillis();
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

}
